package utils;

/**
 * @Author: DRevelation
 * @Date: 2020/12/9 16:36
 * 判断后缀类型工具类
 */
public enum SuffixTypeUtils {
    //视频
    VIDEO("mp4|MP4", "video"),
    //音频
    AUDIO("mp3|MP3", "audio"),
    //图片
    IMAGE("img|IMG|png|PNG", "image");

    private String suffix;
    private String type;

    SuffixTypeUtils(String suffix, String type) {
        this.suffix = suffix;
        this.type = type;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public static String getSuffixType(String suffix) {
        if (VIDEO.getSuffix().contains(suffix)) {
            return VIDEO.getType();
        } else if (AUDIO.getSuffix().contains(suffix)) {
            return AUDIO.getType();
        } else  if (IMAGE.getSuffix().contains(suffix)) {
            return IMAGE.getType();
        } else {
            return null;
        }
    }

    public static void main(String[] args) {
        String suffix = "img";
        String type = SuffixTypeUtils.getSuffixType(suffix);
        System.out.println("type = " + type);
    }
}
